package com.jsgt.greekfire.ui.dialog

import android.app.Dialog
import android.os.Bundle
import android.widget.ImageView
import android.widget.TextView
import com.jsgt.greekfire.R
import com.jsgt.greekfire.base.BaseBottomDialogFragment
import org.jetbrains.anko.find

class SafetyDialog : BaseBottomDialogFragment() {
    lateinit var okListener: () -> Unit

    fun okListener(okListener: () -> Unit): SafetyDialog {
        this.okListener = okListener
        return this
    }


    override fun getLayoutId(): Int {
        return R.layout.dialog_safety
    }

    override fun getDialogStyle(): Int {
        return R.style.DialogTheme
    }

    override fun canCancel(): Boolean {
        return false
    }

    override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
        val dialog = super.onCreateDialog(savedInstanceState)
        dialog.find<ImageView>(R.id.imvClose).setOnClickListener {
            dismiss()
        }
        dialog.find<TextView>(R.id.txvOk).setOnClickListener {
            okListener.invoke()
            dismiss()
        }
        dialog.find<TextView>(R.id.txvCancel).setOnClickListener {
            dismiss()
        }
        return dialog
    }
}